using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace StupidSpaceThing
{
	internal static partial class LevelSystem
	{
		private static int pylonsCaught;

		private static void level1() {
			pylonsCaught = 0;
			// neutral		
			TradePortal tradePortal = new TradePortal(Game1.CurMap.Center, (float)(Math.PI / 2), 100, 1);
			Faction.None.Add(tradePortal);

			// factions
			new Blue(Game1.CurMap.TopLeft + new Vector3(-20, 0, -20));
			new Yellow(Game1.CurMap.TopRight + new Vector3(20, 0, -20));
			new Red(Game1.CurMap.BottomRight + new Vector3(20, 0, 20));
			new Green(Game1.CurMap.BottomLeft + new Vector3(-20, 0, 20));

			//Faction.None.Add(new JellyFish(CurMap.Center + new Vector3(0, 0, -50)));
			Map.Cell freeCell = null;
			for( int i = 0; i < 30; i++ ) {
				Faction mineFaction = Faction.RandomFaction();
				freeCell = Game1.CurMap.GetFreeCell(mineFaction.Hive.Position, 20);
				mineFaction.Add(new Mine(new Vector3(freeCell.X * Game1.CurMap.CellSize, 0, freeCell.Z * Game1.CurMap.CellSize)));
			}

			Pylon pylon = null;
			freeCell = Game1.CurMap.GetFreeCell(Faction.Red.Hive.Position, 10);
			pylon = new Pylon(new Vector3(freeCell.X * Game1.CurMap.CellSize, 0, freeCell.Z * Game1.CurMap.CellSize));			
			Faction.Red.Add(pylon);
			freeCell = Game1.CurMap.GetFreeCell(Faction.Yellow.Hive.Position, 10);
			pylon = new Pylon(new Vector3(freeCell.X * Game1.CurMap.CellSize, 0, freeCell.Z * Game1.CurMap.CellSize));
			pylon.SetLastForce(new Vector2(0, 1));
			Faction.Yellow.Add(pylon);
			freeCell = Game1.CurMap.GetFreeCell(Faction.Blue.Hive.Position, 10);
			pylon = new Pylon(new Vector3(freeCell.X * Game1.CurMap.CellSize, 0, freeCell.Z * Game1.CurMap.CellSize));
			pylon.SetLastForce(new Vector2(0, 1));
			Faction.Blue.Add(pylon);
			freeCell = Game1.CurMap.GetFreeCell(Faction.Green.Hive.Position, 10);
			Faction.Green.Add(new Pylon(new Vector3(freeCell.X * Game1.CurMap.CellSize, 0, freeCell.Z * Game1.CurMap.CellSize)));

			//Point? point = CurMap.CheckCollision(new Vector2(0, 0), new Vector2(10, 10));
			freeCell = Game1.CurMap.GetFreeCell(tradePortal.Position, 5);
			Game1.Player = new Player(new Vector3(freeCell.X * Game1.CurMap.CellSize, Map.MaxHeight + 0.2f, freeCell.Z * Game1.CurMap.CellSize));
			Game1.Player.Entity.Armor = 1;
			Game1.Player.CanShoot = false;
			Scorpion._ProductionCost = 500;
			Scorpion._ProductionTime = 1000;
			Faction.None.Add(Game1.Player);
		}
		
		public static void Level1_CatchPylon(){
			pylonsCaught++;
			switch( pylonsCaught ){
				case 1:
					GuideSystem.ShowPriority(new TextGuide("Good, now get the remaining three", Game1.SpriteFont, TextAlign.Both, 3000));
					break;
				case 2:
					GuideSystem.ShowPriority(new TextGuide("Halfway, keep going", Game1.SpriteFont, TextAlign.Both, 3000));
					break;
				case 3:
					GuideSystem.ShowPriority(new TextGuide("Last one, hurry!", Game1.SpriteFont, TextAlign.Both, 3000));
					break;
				case 4:
					GuideSystem.ShowPriority(new TextGuide("Nice work, mission accomplished", Game1.SpriteFont, TextAlign.Both, 1, Color.White, 5000, delegate() {
						Game1.Level = 2;
						Game1.Game.Reset();
					}), true);
					break;
			}
		}
	}
}
